package com.glela.order.model.response;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.glela.order.model.PayTypeConfig;
import com.glela.order.model.response.order.RespPromotionVo;
import com.glela.order.model.vo.order.ErrorMsgVo;
import com.glela.order.model.vo.order.UserRedPacketVo;
import com.glela.order.model.vo.order.UserWalletVo;
import com.glela.order.vo.PollingConfig;
import com.glela.platform.vo.UserPromotionVo;

/**
 * 订单结算响应结果
 * @author zls
 *
 */
public class RespAddOrderInfo {
	@JsonIgnoreProperties(ignoreUnknown = true)
	private long	pId;
	@JsonIgnoreProperties(ignoreUnknown = true)
	private boolean	clearCart;

	private boolean						openStoreOrder;												//开店订单
	private String						token;														//重复提交验证
	private boolean						paid;														//是否已支付
	private boolean						payable;													//是否可支付
	private boolean						pwdAvail;													//密码是否正确
	private String						orderSn;													//结算单号
	private long						totalPrice;													//总实际售价
	private long						totalProd;													//宗商品件数
	private long						acquirableXzb;												//获得获得妆币
	private long						discountFee;												//折扣金额
	private int							freight;
	private UserWalletVo				userMoney			= new UserWalletVo();
	private Collection<UserPromotionVo>	userPromotionList	= new LinkedList<UserPromotionVo>();	//优惠券
	private List<PayTypeConfig>			payTypeConfigList	= new LinkedList<PayTypeConfig>();		//支付方式
	private ErrorMsgVo					errorMsg			= new ErrorMsgVo();
	private int							orderUploadType		= 1;
	private PollingConfig				pollingConfig;
	private UserRedPacketVo				redPacket;													//用户默认红包
	private RespPromotionVo				promotion;													//用户默认优惠券

	public PollingConfig getPollingConfig() {
		return pollingConfig;
	}

	public void setPollingConfig(PollingConfig pollingConfig) {
		this.pollingConfig = pollingConfig;
	}

	public int getOrderUploadType() {
		return orderUploadType;
	}

	public void setOrderUploadType(int orderUploadType) {
		this.orderUploadType = orderUploadType;
	}

	public void clear() {
		errorMsg.clear();
		getPayTypeConfigList().clear();
		getUserPromotionList().clear();
		setRedPacket(null);
		setPromotion(null);
	}

	public boolean isOpenStoreOrder() {
		return openStoreOrder;
	}

	public void setOpenStoreOrder(boolean openStoreOrder) {
		this.openStoreOrder = openStoreOrder;
	}

	public String getToken() {
		return token;
	}

	public long getDiscountFee() {
		return discountFee;
	}

	public void setDiscountFee(long discountFee) {
		this.discountFee = discountFee;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public boolean isPaid() {
		return paid;
	}

	public void setPaid(boolean paid) {
		this.paid = paid;
	}

	public boolean isPayable() {
		return payable;
	}

	public void setPayable(boolean payable) {
		this.payable = payable;
	}

	public boolean isPwdAvail() {
		return pwdAvail;
	}

	public void setPwdAvail(boolean pwdAvail) {
		this.pwdAvail = pwdAvail;
	}

	public String getOrderSn() {
		return orderSn;
	}

	public void setOrderSn(String orderSn) {
		this.orderSn = orderSn;
	}

	public List<PayTypeConfig> getPayTypeConfigList() {
		return payTypeConfigList;
	}

	public void setPayTypeConfigList(List<PayTypeConfig> payTypeConfigList) {
		this.payTypeConfigList = payTypeConfigList;
	}

	public ErrorMsgVo getErrorMsg() {
		return errorMsg;
	}

	public long getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(long totalPrice) {
		this.totalPrice = totalPrice;
	}

	public long getTotalProd() {
		return totalProd;
	}

	public int getFreight() {
		return freight;
	}

	public UserWalletVo getUserMoney() {
		return userMoney;
	}

	public void setUserMoney(UserWalletVo userMoney) {
		this.userMoney = userMoney;
	}

	public Collection<UserPromotionVo> getUserPromotionList() {
		return userPromotionList;
	}

	public void setTotalProd(long totalProd) {
		this.totalProd = totalProd;
	}

	public long getAcquirableXzb() {
		return acquirableXzb;
	}

	public void setAcquirableXzb(long acquirableXzb) {
		this.acquirableXzb = acquirableXzb / 100;
	}

	public void setFreight(int freight) {
		this.freight = freight;
	}

	public long getpId() {
		return pId;
	}

	public void setpId(long pId) {
		this.pId = pId;
	}

	public boolean isClearCart() {
		return clearCart;
	}

	public void setClearCart(boolean clearCart) {
		this.clearCart = clearCart;
	}

	public UserRedPacketVo getRedPacket() {
		return redPacket;
	}

	public void setRedPacket(UserRedPacketVo redPacket) {
		this.redPacket = redPacket;
	}

	public RespPromotionVo getPromotion() {
		return promotion;
	}

	public void setPromotion(RespPromotionVo promotion) {
		this.promotion = promotion;
	}

	/** 是否有默认红包 */
	public boolean hasDefaultRedPacket() {
		return getRedPacket() != null;
	}

	/** 是否有默认优惠券 */
	public boolean hasDefaultPromotion() {
		return getTotalPrice() - getDiscountFee() > 0 && getUserPromotionList().size() > 0;
	}

	/** 是否有默认红包 */
	public boolean isHasDefaultRedPacket() {
		return getRedPacket() != null;
	}

	/** 是否有优惠券 */
	public boolean isHasRedPacket() {
		return isHasDefaultRedPacket();
	}

	/** 是否有默认优惠券 */
	public boolean isHasDefaultPromotion() {
		return getPromotion() != null;
	}

	/** 是否有优惠券 */
	public boolean isHasPromotion() {
		return getUserPromotionList().size() > 0;
	}
}